//
//  BillboardView.m
//  Flava
//
//  Created by Ug-Code on 13-8-14.
//  Copyright (c) 2013年 UgCode. All rights reserved.
//

#import "BillboardView.h"


#define kBillboardView_X 0
#define kBillboardView_Y 5
#define kBillboardView_Y_7 0
#define kBillboardView_W 320
#define kBillboardView_H 175

@implementation BillboardView

@synthesize
imageArrey = _imageArrey,
userAvatarsImage = _userAvatarsImage,
userName = _userName,
userBirthday = _userBirthday;

- (id)init
{
    self = [super init];
    if (self) {
        _imageView = [[UIImageView alloc] init];
		_imageArrey = [[NSMutableArray alloc] init];
		//适配iOS7
		if ([UGDevice systemVersion] >= 7) {
			//iOS7或更高版本
			self.frame = CGRectMake(kBillboardView_X, kBillboardView_Y_7, kBillboardView_W, kBillboardView_H);
			_imageView.frame = CGRectMake(0, 0, kBillboardView_W, kBillboardView_H);
			UGView *blurView = [[UGView alloc] init];
			blurView.frame = CGRectMake(0, 0, 320, 20);
			blurView.backgroundColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:0.2];
			[_imageView addSubview:blurView];
		} else {
			self.frame = CGRectMake(kBillboardView_X, kBillboardView_Y, kBillboardView_W, kBillboardView_H);
			_imageView.frame = CGRectMake(0, 0, kBillboardView_W, kBillboardView_H);
		}
		self.clipsToBounds = YES; //超出范围的图片裁剪掉
		[self addSubview:_imageView];
		//--用户头像
		_avatarsView = [AvatarsView leftSquareAvatarsView];
		[self addSubview:_avatarsView];
		//--背景图片集
		[self createImageArray];
		_imageView.image = self.imageArrey[3];
		//--
		[self createUserNameLable];
		[self createUserBirthdayLable];
    }
    return self;
}

- (void)createImageArray
{
	for (int i = 0; i < 5; i++) {
		UIImage *image =
			[UIImage imageNamed:[NSString stringWithFormat:@"default_slide_images_0%d.jpg", i]];
		[_imageArrey addObject:image];
	}
}

- (void)createUserNameLable
{
	_userNameLable = [[UILabel alloc] init];
	_userNameLable.frame = CGRectMake(75, 110, 180, 37);
	_userNameLable.textColor = [UIColor whiteColor];
	_userNameLable.backgroundColor = UGAlphaColor;
	_userNameLable.font = [UIFont systemFontOfSize:23];
	_userNameLable.shadowColor = [UIColor grayColor];
	_userNameLable.shadowOffset = CGSizeMake(0, 1);
	[self addSubview:_userNameLable];
}

- (void)createUserBirthdayLable
{
	_userBirthdayLable = [[UILabel alloc] init];
	_userBirthdayLable.frame = CGRectMake(75, 145, 63, 11);
	_userBirthdayLable.textColor = [UIColor whiteColor];
	_userBirthdayLable.backgroundColor = UGAlphaColor;
	_userBirthdayLable.font = [UIFont systemFontOfSize:11];
	_userBirthdayLable.shadowColor = [UIColor grayColor];
	_userBirthdayLable.shadowOffset = CGSizeMake(0, 1);
	[self addSubview:_userBirthdayLable];
}

/** 存入用户头像 */
- (void)setUserAvatarsImage:(UIImage *)image
{
	_avatarsView.image = image;
}

/** 存入用户名 */
- (void)setUserName:(NSString *)name
{
	_userNameLable.text = name;
}

/** 存入用户生日 */
-(void)setUserBirthday:(NSString *)day
{
	_userBirthdayLable.text = day;
}

/** 更新背景图片集 */
- (void)upDateImages:(NSMutableArray *)array
{
	self.imageArrey = array;
}

- (void)animation
{
	
}

- (void)startAnimating
{
	
}

- (void)stopAnimating
{
	
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
